<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <% include("../inc/input_css.html"){}%>
    <style>
        .control-label{
            width: 220px!important;
        }
    </style>

    <%
    var isAdd = false;
    var isEdit = false;
    if(isEmpty(paymentConfig.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span class="current">商城设置</span>
            <span class="line">/</span>
            <span class="current"><a href="list">支付方式</a></span><span class="line">/</span>
            <%if(isAdd){%>添加支付方式<%}else{%>编辑支付方式<%}%>
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="padding-40">
                    <form class="form-horizontal form-validate" method="post" id="form" action="<%if (isAdd){%>save<%}else{%>update<%}%>"  >
                        <input type="hidden" name="paymentConfig.id" value="${paymentConfig.id!}" />
                        <table class="input tabContent">

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>支付方式</label>
                                <div class="col-sm-3">
                                    <select name="paymentConfigType" id="paymentConfigType"class="form-control light-input" required>
                                        <%for(list in allPaymentConfigType){%>
                                        <option value="${list}"<%if (list == paymentConfig.paymentConfigTypeValue!){%> selected<%}%>>
                                        ${i18n("PaymentConfigType." + list)}
                                        </option>
                                        <%}%>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>支付方式名称</label>
                                <div class="col-sm-3">
                                    <input type="text" name="paymentConfig.name" id="paymentConfigName" value="${paymentConfig.name!}" class="form-control light-input" required>
                                </div>

                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">支付手续费设置</label>
                                <div class="col-sm-3 col-md-3  col-lg-2 ">
                                    <div class="right_cont_r radio i-checks">
                                        <%for(list in allPaymentFeeType){%>
                                            <input type="radio" name="paymentFeeType" value="${list}"<%if ((isAdd && list == "scale") || list == paymentConfig.paymentFeeTypeValue!){%> checked <%}%>>
                                            ${i18n("PaymentFeeType." + list)}
                                        <%}%>

                                    </div>
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>支付费率/固定费用</label>
                                <div class="col-sm-3">
                                    <input type="text" name="paymentConfig.paymentFee"  value="${paymentConfig.paymentFee!0}" class="form-control light-input" required>
                                </div>

                            </div>

                            <!-- 财付通 begin-->
                            <div class="tenpayConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "tenpay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label">财付通交易类型</label>
                                <div class="col-sm-3" >
                                    <select name="tenpayType" class="form-control light-input">
                                        <%for(list in allTenpayType){%>
                                        <option value="${list}"<%if (list == tenpayConfig.tenpayType!){%> selected<%}%>>
                                        ${i18n("TenpayType." + list)}
                                        </option>
                                        <%}%>
                                    </select>
                                </div>
                            </div>
                            <div class="tenpayConfigTr form-group" style="display:<%if (isAdd || paymentConfig.paymentConfigTypeValue != "tenpay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>财付通商户号</label>
                                <div class="col-sm-3">
                                    <input type="text" name="tenpayConfig.bargainorId"  value="${tenpayConfig.bargainorId!}" class="form-control light-input" required>
                                </div>

                            </div>

                            <div class="tenpayConfigTr form-group" style="display:<%if (isAdd || paymentConfig.paymentConfigTypeValue != "tenpay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>财付通密钥</label>
                                <div class="col-sm-3">
                                    <input type="text" name="tenpayConfig.key"  value="${tenpayConfig.key!}" class="form-control light-input" required>
                                </div>

                            </div>
                            <!-- 财付通 end-->
                            <!-- 支付宝 begin-->
                            <!--<div class="alipayConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "alipay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label">支付宝交易类型</label>
                                <div class="col-sm-3" >
                                    <select name="alipayType" class="form-control light-input">
                                        <%for(list in allAlipayType){%>
                                            <option value="${list}"<%if (list == alipayConfig.alipayType!){%> selected<%}%>>
                                            ${i18n("AlipayType." + list)}
                                            </option>
                                        <%}%>
                                    </select>
                                </div>
                            </div>-->
                            <div class="alipayConfigTr form-group" style="display:<%if (isAdd || paymentConfig.paymentConfigTypeValue != "alipay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>支付宝商户号</label>
                                <div class="col-sm-3">
                                    <input type="text" name="alipayConfig.bargainorId"  value="${alipayConfig.bargainorId!}" class="form-control light-input" required>
                                </div>

                            </div>
                            <div class="alipayConfigTr form-group" style="display:<%if (isAdd || paymentConfig.paymentConfigTypeValue != "alipay"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>支付宝商户号</label>
                                <div class="col-sm-3">
                                    <input type="text" name="alipayConfig.key"  value="${alipayConfig.key!}" class="form-control light-input" required>
                                </div>

                            </div>
                            <!-- 支付宝end; -->

                            <!-- 微信 begin-->
                            <div class="weixinConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "weixin"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>AppID(应用ID)</label>
                                <div class="col-sm-3">
                                    <input type="text" name="weixinConfig.appid"  value="${weixinConfig.appid!}" class="form-control light-input" required>
                                </div>
                            </div>
                            <div class="weixinConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "weixin"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>AppSecret(应用密钥)</label>
                                <div class="col-sm-3">
                                    <input type="text" name="weixinConfig.secret"  value="${weixinConfig.secret!}" class="form-control light-input" required>
                                </div>
                            </div>
                            <div class="weixinConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "weixin"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>微信支付商户号(MchId)</label>
                                <div class="col-sm-3">
                                    <input type="text" name="weixinConfig.bargainorId"  value="${weixinConfig.bargainorId!}" class="form-control light-input" required>
                                </div>
                            </div>
                            <div class="weixinConfigTr form-group" style="display: <%if (isAdd || paymentConfig.paymentConfigTypeValue != "weixin"){%> none<%}%> ">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>商户支付秘钥</label>
                                <div class="col-sm-3">
                                    <input type="text" name="weixinConfig.key"  value="${weixinConfig.key!}" class="form-control light-input" required>
                                </div>
                            </div>
                            <!-- 微信end; -->

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>排序</label>
                                <div class="col-sm-3">
                                    <input type="text" name="paymentConfig.orderList"  value="${paymentConfig.orderList!50}" class="form-control light-input" required="true">
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">介绍</label>
                                <div class="col-sm-3">
                                    <textarea name="paymentConfig.description" rows="8" cols="80" class="form-control light-input">${paymentConfig.description!}</textarea>
                                </div>

                            </div>
                        </table>
                        <div class="form-group" style="margin-top: 24px">
                            <label class="col-sm-2 control-label "></label>
                            <div class="col-sm-4 col-sm-offset-0">
                                <button class="hive-btn-cancle" id="btn_cancle" type="button" onclick="history.back()">&nbsp;取消&nbsp;</button>
                                <button class="hive-btn hive-btn-primary margin-left-8" type="submit">&nbsp;提交&nbsp;
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<% include("../inc/input_js.html"){}%>

<!-- 自定义js -->
<script src="/res/js/jquery-migrate-1.2.1.js"></script><!--jquery1.9 以上补丁-->
<script type="text/javascript">
    var uploadUrl="/file/uploadfile?shopId=${shopId!}&type=d";
    var browserUrl="/file/browser?shopId=${shopId!}";
</script>
<script src="https://static.9hive.cn/global/vendor/file/file.js"></script>
<script type="text/javascript">
    $(function () {
        $("input.browserButton").browser();
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_flat-blue',
            radioClass: 'iradio_flat-blue',
        });
    })


</script>
<script type="text/javascript">
    $().ready( function() {

        var $paymentConfigTypeSelect = $("select[name='paymentConfigType']");
        var $tenpayConfigTr = $(".tenpayConfigTr");
        var $tenpayInput = $(".tenpayConfigTr :input");

        var $alipayConfigTr = $(".alipayConfigTr");
        var $alipayInput = $(".alipayConfigTr :input");

        var $weixinConfigTr=$(".weixinConfigTr");
        var $weixinInput = $(".weixinConfigTr :input");

        // 根据支付类型显示/隐藏输入项
        $paymentConfigTypeSelect.change( function() {
            var $this = $(this);
            if ($this.val() == "tenpay") {
                $tenpayInput.removeClass("ignoreValidate");
                $tenpayConfigTr.show();
                $alipayConfigTr.hide();
                $weixinConfigTr.hide();
            } else if($this.val() == "alipay") {
                $alipayInput.removeClass("ignoreValidate");
                $alipayConfigTr.show();
                $tenpayConfigTr.hide();
                $weixinConfigTr.hide();
            } else if($this.val() == "weixin") {
                $weixinInput.removeClass("ignoreValidate");
                $weixinConfigTr.show();
                $alipayConfigTr.hide();
                $tenpayConfigTr.hide();
            } else {
                $tenpayInput.addClass("ignoreValidate");
                $tenpayConfigTr.hide();
                $alipayInput.addClass("ignoreValidate");
                $alipayConfigTr.hide();
                $weixinInput.addClass("ignoreValidate");
                $weixinConfigTr.hide();
            }
        });

    });
</script>

<script type="text/javascript">
    function check(){
        var paymentConfigName=$("#paymentConfigName").val();
        var paymentConfigType=$("#paymentConfigType").val();//支付类型
        var paymentConfigOrderList=$("#paymentConfigOrderList").val();
        var listReg=/^\d*\d*\d+$/;

        if(!paymentConfigName){
            layer.msg("请填写支付方式名称!");
            return false;
        }
        if(paymentConfigType=='tenpay'){
            var tenpayConfigBargainorId=$("input[name='tenpayConfig.bargainorId']").val();//财付通商户号:
            var tenpayConfigKey=$("input[name='tenpayConfig.key']").val();//财付通宝密钥
            if(!tenpayConfigBargainorId){
                layer.msg("财付通商户号不能为空");
                return false
            }
            if(!tenpayConfigKey){
                layer.msg("财付通密钥不能为空");
                return false
            }
        }
        if(paymentConfigType=='alipay'){
            var alipayConfigBargainorId=$("input[name='alipayConfig.bargainorId']").val();//支付宝商户号:
            var alipayConfigKey=$("input[name='alipayConfig.key']").val();//支付宝密钥
            if(!alipayConfigBargainorId){
                layer.msg("支付宝商户号不能为空");
                return false
            }
            if(!alipayConfigKey){
                layer.msg("支付宝密钥不能为空");
                return false
            }

        }
        if(paymentConfigType=='weixin'){
            var weixinConfigAppid=$("input[name='weixinConfig.appid']").val();//AppID(应用ID)
            var weixinConfigsecret=$("input[name='weixinConfig.secret']").val();//AppID(应用ID)
            var weixinConfigBargainorId=$("input[name='weixinConfig.bargainorId']").val();//支付宝商户号
            var weixinConfigKey=$("input[name='weixinConfig.key']").val();//支付宝密钥
            if(!weixinConfigAppid){
                layer.msg("AppID(应用ID) 不能为空");
                return false
            }
            if(!weixinConfigsecret){
                layer.msg("AppSecret(应用密钥) 不能为空");
                return false
            }
            if(!weixinConfigBargainorId){
                layer.msg("微信支付商户号不能为空");
                return false
            }
            if(!weixinConfigKey){
                layer.msg("商户支付秘钥不能为空");
                return false
            }

        }
        if(!listReg.test(paymentConfigOrderList) || parseInt(paymentConfigOrderList)>999){
            layer.msg("排序请输入0-999的正整数!");
            return false;
        }

    }
</script>
</body>
</html>